
const packageJson = require('../package.json')

const minVersion = "20.1.0"
const currentNodeVersion = process.versions.node
const isPnpm = process.env.npm_execpath && process.env.npm_execpath.indexOf('pnpm') !== -1

// 如果不是pnpm安装，退出
if (!isPnpm) {
  console.error('Please use pnpm to install.')
  process.exit(1);
}
// 如果当前node版本小于最低版本，退出
if (!compareVersion(currentNodeVersion)) {
  console.error(`Required node version ${minVersion} not satisfied with current version ${currentNodeVersion}`);
  process.exit(1);
}
function compareVersion(cur) {
  const num1 = cur.split('.').join('')
  const num2 = minVersion.split('.').join('')
  return num1 >= num2
}
